import mockApi from "@/api/mockApi";

export default class buildingApi {
  static buildings = [
    {id: 1, buildingName: '北区1栋', address: '熏衣区望北街1号', floorCount: 42, roomCount: 256, createTime: '2024-01-01 12:12:12', modifyTime: '2024-02-02 13:13:13'},
    {id: 2, buildingName: '北区2栋', address: '熏衣区望北街2号', floorCount: 43, roomCount: 267, createTime: '2024-02-02 12:12:12', modifyTime: '2024-03-03 13:13:13'},
    {id: 3, buildingName: '北区3栋', address: '熏衣区望北街3号', floorCount: 44, roomCount: 278, createTime: '2024-03-03 12:12:12', modifyTime: '2024-04-04 13:13:13'},
    {id: 4, buildingName: '北区4栋', address: '熏衣区望北街4号', floorCount: 45, roomCount: 289, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'}
  ]

  static async save (params) {
    console.log('buildingApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('buildingApi find params', params)
    const response = await mockApi.queryPageSuccessfully(buildingApi.buildings)
    return response.data
  }

  static async findById (id) {
    console.log('buildingApi findById id', id)
    let target = {}
    for (let a of buildingApi.buildings) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('buildingApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}